package com.eddie.community.service;

import com.eddie.community.entity.LoginTicket;
import com.eddie.community.entity.User;
import com.eddie.community.util.RedisKeyUtil;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * Description:用户服务接口
 * Date: 2021/2/27 0027 15:15
 * Author: eddie_zhan@yeah.net
 */
public interface UserService {

    /***
     * Description:根据id查找用户
     * @params [id]
     * @return com.eddie.community.entity.User
     * @date 2021/2/27 0027 15:28
     * @Author Eddie.Zhan
     */
    User findUserById(int id);

    /**
     * Description:注册
     *
     * @return java.util.Map<java.lang.String, java.lang.Object>
     * @params [user]
     * @date 2021/2/27 0027 15:20
     * @Author Eddie.Zhan
     */
    Map<String, Object> register(User user);

    /**
     * Description:验证码激活
     *
     * @return int
     * @params [userId, code]
     * @date 2021/2/27 0027 15:28
     * @Author Eddie.Zhan
     */
    int activation(int userId, String code);

    /**
     * Description: 登录
     *
     * @return java.util.Map<java.lang.String, java.lang.Object>
     * @params [username, password, expired]
     * @date 2021/2/27 0027 15:30
     * @Author Eddie.Zhan
     */
    Map<String, Object> login(String username, String password, int expired);

    /**
     * Description: 退出
     *
     * @return void
     * @params [ticket]
     * @date 2021/2/27 0027 15:32
     * @Author Eddie.Zhan
     */
    void logout(String ticket);

    /**
     * Description: 根据ticket值查询登录凭证
     *
     * @return com.eddie.community.entity.LoginTicket
     * @params [ticket]
     * @date 2021/2/27 0027 15:32
     * @Author Eddie.Zhan
     */
    LoginTicket findLoginTicketByTicket(String ticket);

    /***
     * Description: 更新头像
     * @params [userId, headerUrl]
     * @return int
     * @date 2021/2/27 0027 15:32
     * @Author Eddie.Zhan
     */
    int updateHeader(int userId, String headerUrl);


    /**
     * Description: 根据用户名查找用户
     *
     * @return com.eddie.community.entity.User
     * @params [username]
     * @date 2021/2/28 0028 15:16
     * @Author Eddie.Zhan
     */
    User findUserByName(String username);

    /**
     * Description: 查询授权
     *
     * @return java.util.Collection<? extends org.springframework.security.core.GrantedAuthority>
     * @params [userId]
     * @date 2021/3/4 0004 14:37
     * @Author Eddie.Zhan
     */
    Collection<? extends GrantedAuthority> getAuthorities(int userId);
/*
    // 1.优先从缓存中取值
    User getCache(int userId);

    // 2.取不到时初始化缓存数据
    User initCache(int userId);

    // 3.数据变更时清除缓存数据
    void clearCache(int userId);
*/

    /**
     * Description: 查询具有角色的用户（达人，管理员）
     *
     * @return java.util.List<com.eddie.community.entity.User>
     * @params []
     * @date 2021/3/11 0011 16:29
     * @Author Eddie.Zhan
     */
    List<User> findHasRoleUser(int offset, int limit);

    /**
        * Description: 修改用户类型
        * @params [userId, type]
        * @return int
        * @date 2021/3/13 0013 20:04
        * @Author Eddie.Zhan
        */
    int changeType(int userId,int type);

    /**
        * Description: 修改激活状态
        * @params [Status]
        * @return int
        * @date 2021/3/13 0013 22:10
        * @Author Eddie.Zhan
        */
    int changeStatus(int userId,int Status);

    /**
        * Description: 查询激活状态
        * @params [userId]
        * @return int
        * @date 2021/3/13 0013 22:11
        * @Author Eddie.Zhan
        */
    int findStatus(int userId);
}
